import { defineStore } from 'pinia';

export const useCompanyStore = defineStore('company', {
	state: () => {
		return {
			// 当前公司信息
			curCompanyInfo: null,
			// 轮播图列表
			bannerList: null,
			// 园区数据
			parkData: null,
		};
	},

	getters: {
		// 获取当前公司信息
		GetCurCompanyInfo: (state) => () => { return state.curCompanyInfo || uni.getStorageSync('currentCompanyInfo'); },

		// 获取轮播图列表
		GetBannerList: (state) => () => { return state.bannerList || uni.getStorageSync('bannerList'); },

		// 获取园区数据
		GetParkData: (state) => () => { return state.parkData; },
	},

	actions: {
		// 设置当前公司信息
		setCurCompanyInfo(data) {
			this.curCompanyInfo = data;
			uni.setStorageSync('currentCompanyInfo', this.curCompanyInfo);
		},

		setBannerList(data) {
			this.bannerList = data;
			uni.setStorageSync('bannerList', this.bannerList);
		},

		// 设置园区数据和刷新时间
		setParkData(data) {
			this.parkData = data;
		},
	},
});